package com.zy.qudadid.presenter;

import com.zy.qudadid.model.GuDingLuCheng;
import com.zy.qudadid.model.Res;
import com.zy.qudadid.network.Const;
import com.zy.qudadid.network.Net;
import com.zy.qudadid.presenter.base.RefreshAndLoadMorePresenter;
import com.zy.qudadid.ui.view.IndexAllView;

import java.util.ArrayList;

import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by ninos on 2016/9/20.
 */
public class IndexAllPresenter extends RefreshAndLoadMorePresenter<IndexAllView> {
    @Override
    public void getData(int page, int count) {

    }

    public void GetNearbyDriver(String data){
        Subscription subscription = Net.getService()
                .GetNearbyDriver("")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<Res<ArrayList<GuDingLuCheng>>>() {

                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        view.error();
                    }

                    @Override
                    public void onNext(Res<ArrayList<GuDingLuCheng>> res) {
                        if (res.code== Const.OK){
                            view.success(res.datas);
                        }else {
                            view.error();
                        }
                    }
                });

        addSubscription(subscription);
    }


}
